Page({
    mixins: [require('../../mixin/themeChanged')],
    data: {
        inputShowed: false,
        inputVal: '',
        list: [123123, 1111, 2222, 344333, 4444],
        classify: [{
                id: 1,
                image: 'https://p4.img.cctvpic.com/photoAlbum/page/performance/img/2021/3/25/1616638385071_582.jpg',
                text: '十九届六中全会素材',

            },
            {
                id: 2,
                image: 'https://p4.img.cctvpic.com/photoAlbum/page/performance/img/2021/3/25/1616638385071_582.jpg',
                text: '党的光辉历史素材'
            },
            {
                id: 3,
                image: 'https://p4.img.cctvpic.com/photoAlbum/page/performance/img/2021/3/25/1616638385071_582.jpg',
                text: '抗疫一线素材'
            },
            {
                id: 4,
                image: 'https://p4.img.cctvpic.com/photoAlbum/page/performance/img/2021/3/25/1616638385071_582.jpg',
                text: '感动中国人物素材'
            },
            {
                id: 5,
                image: 'https://p4.img.cctvpic.com/photoAlbum/page/performance/img/2021/3/25/1616638385071_582.jpg',
                text: '国家成就素材 '
            },
            {
                id: 6,
                image: 'https://p4.img.cctvpic.com/photoAlbum/page/performance/img/2021/3/25/1616638385071_582.jpg',
                text: '时代伟人素材'
            },
            {
                id: 7,
                image: 'https://p4.img.cctvpic.com/photoAlbum/page/performance/img/2021/3/25/1616638385071_582.jpg',
                text: '基层人物事迹素材'
            },
        ],
        show: false,
        searchTips: []
    },
    show() {
        this.setData({
            show: true
        })
    },
    showInput() {
        this.setData({
            inputShowed: true
        });
    },
    hideInput() {
        this.setData({
            inputVal: "",
            inputShowed: false
        });
    },
    clearInput() {
        this.setData({
            inputVal: ""
        });
    },
    inputTyping(e) {
        this.setData({
            inputVal: e.detail.value
        })
        const newTips = []
        const newClassify = this.data.classify.filter(i => i.text.indexOf(this.data.inputVal) !== -1)
        if (newClassify.length >= 1) {
            newClassify.forEach(i => {
                newTips.push(i.text)
            })
            this.setData({
                searchTips: newTips
            })
        } else {
            this.setData({
                searchTips: [`没有关于的${e.detail.value}的素材库`]
            })
        }
    },
    searchText(e) {
        console.log(e);
    },
    jump(e) {
        console.log(e.currentTarget.dataset['text']);
        wx.redirectTo({
            url: '/pages/detail',
        })
    }
})